#include <stdio.h>
#include <stdlib.h>

// getchar
// putchar

int hex_digit(int n) {
	if('0' <= n && n <= '9') {
		return n - '0';
	}
	
	if('a' <= n && n <= 'f') {
		return n - 'a' + 10;
	}
	
	if('A' <= n && n <= 'F') {
		return n - 'A' + 10;
	}
	
	exit(-1);
}

void skip_comment() {
	int nyb;
	
	do {
		nyb = getchar();
		if(nyb == EOF) exit(-1);
		if(nyb == '\n') return;
	} while(1);
}

int main(void) {
	int nyb, oct;

	do {
		nyb = getchar();
		if(nyb == EOF) {
			return 0;
		}
		else if(nyb == '#') {
			skip_comment();
			continue;
		}
		else if(nyb == ' ' || nyb == '\t' || nyb == '\n') {
			continue;
		}
		
		nyb = hex_digit(nyb);
		oct = nyb << 4;
		nyb = getchar();
		nyb = hex_digit(nyb);
		oct |= nyb;

		putchar(oct);
	} while(1);
}
